package org.dev.vlp.controller;

import org.dev.vlp.bean.JsonResponse;
import org.dev.vlp.constants.EnumNotificationCategory;
import org.dev.vlp.constants.Roles;
import org.dev.vlp.dto.PublishCommentParam;
import org.dev.vlp.interceptor.RequiredPermission;
import org.dev.vlp.service.NotificationService;
import org.dev.vlp.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Description
 * Param
 * return
 * Author:86184
 * Date: 2023/1/14
 */
@RestController
@RequestMapping("/notification")
@RequiredPermission({Roles.ROLE_USER})
public class NotificationController extends BaseController {
    @Autowired
    private NotificationService notificationService;

    @PostMapping("/comment")
    public JsonResponse<PageResult> queryCommentInfo(@RequestParam int page,
                                                     @RequestParam int size) {
        PageResult pageResult = notificationService.queryCommentInfo(page, size, getUid());
        return JsonResponse.success(pageResult);
    }

    @DeleteMapping
    public JsonResponse<Object> clearNotificationCount(@RequestParam EnumNotificationCategory category) {

        notificationService.clearNotificationCount(category,getUid());
        return JsonResponse.success();
    }

    @PostMapping({"/at"})
    public JsonResponse<PageResult> queryAtInfo(@RequestParam int page,
                                                @RequestParam int size) {

        PageResult pageResult = notificationService.queryAtInfo(page,size,getUid());
        return JsonResponse.success(pageResult);
    }

    @PostMapping({"/like"})
    public JsonResponse<PageResult> queryLikeInfo(@RequestParam int page,
                                                          @RequestParam int size) {
        PageResult likeNotificationVo = notificationService.queryLikeInfo(getUid(),page,size);
        return JsonResponse.success(likeNotificationVo);
    }
}
